<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use App\Repositories\QuizRepository;

class QuizRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required|string|max:100',
            'type' => 'required|in:'.implode(',', array_keys(QuizRepository::$types)),
            'options.home_team' => 'nullable|string|max:50',
            'options.home_team_flag' => 'nullable|string|max:512',
            'options.visiting_team' => 'nullable|string|max:50',
            'options.visiting_team_flag' => 'nullable|string|max:512',
            'options.start_at' => 'nullable|date_format:"Y-m-d H:i"',
            'group_id' => 'required|integer',
            'copper_limit' => 'required|integer|max:100000000',
            'is_public' => 'required|boolean',
            'stop_at' => 'required|date_format:"Y-m-d H:i"',
            'items' => 'array',
            'items.*.name' => 'string|max:50',
            'items.*.odds' => 'numeric',
            'form_id' => 'nullable|string|max:128',
        ];
    }
}
